package com.bianguo.android.componentlib;

import com.bianguo.android.componentlib.impl.EmptyLoginService;
import com.bianguo.android.componentlib.impl.EmptyMineService;
import com.bianguo.android.componentlib.service.ILoginService;
import com.bianguo.android.componentlib.service.IMineService;

public class ServiceFactory {

    private static volatile ServiceFactory instance;
    private ILoginService loginService;
    private IMineService mineService;

    private ServiceFactory() {}

    public static ServiceFactory getInstance() {
        ServiceFactory factory = instance;
        if (factory == null) {
            synchronized (ServiceFactory.class) {
                if (factory == null) {
                    factory = new ServiceFactory();
                    instance = factory;
                }
            }
        }
        return factory;
    }

    public ILoginService getLoginService() {
        if (loginService == null) {
            loginService = new EmptyLoginService();
        }
        return loginService;
    }

    public void setLoginService(ILoginService loginService) {
        this.loginService = loginService;
    }

    public IMineService getMineService() {
        if (mineService == null) {
            mineService = new EmptyMineService();
        }
        return mineService;
    }

    public void setMineService(IMineService mineService) {
        this.mineService = mineService;
    }
}
